package com.drcoffee.drcoffeemall.mapper;

import com.drcoffee.drcoffeemall.entry.CssOrientation;
import com.drcoffee.drcoffeemall.entry.Explosion;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/*
 * 爆炸图
 * */

@Mapper
@Repository
public interface ExplosionMapper {
    /* 根据ID查询爆炸图 */
    Explosion getExplosionById(Integer id);

    /* 根据机器Id查询爆炸图 */
    List<Explosion> getExplosionByMachineId(Integer machine_id);

    /* 查询包插图关联的定位点 */
    List<CssOrientation> getCssOrientation(Integer id);


    boolean addExplosion(Explosion explosion);

    boolean deleteExplosion(Integer id);

    boolean addCssOrientation(Integer explosion_id);

    boolean setCssOrientation(CssOrientation cssOrientation);

    void dotSetExplosion(Integer id,Integer decompose_id);

    /* 删除定位点 */
    boolean deleteCssOrientation(Integer id);

    /* 定位点取消分解 */
    boolean setDismantleN(Integer id);


    void bindingPart(@Param("dotId") Integer dotId, @Param("attachments") List<String> attachments);


    @Delete("DELETE FROM t_css_attachment_m WHERE css_id = #{dotId}")
    void delBindPart(Integer dotId);

    void insertData(Map<String, Object> explosion);

    @Select("SELECT t_css_orientation.decompose_id FROM t_css_orientation WHERE id = #{dotId}")
    Integer getCssOrientationDecomposeById(Integer dotId);

    @Update("UPDATE t_css_orientation SET is_fj = #{is_fj} WHERE id = #{dotId}")
    void setIsFj(Integer dotId, String is_fj);

    @Select("SELECT COUNT(0) FROM t_css_attachment_m WHERE css_id = #{dotId}")
    Integer getBindPart(Integer dotId);
}
